package com.agileboot.admin.controller.performance;

import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.domain.performance.submission.SubmissionApplicationService;
import com.agileboot.domain.performance.submission.dto.AuditStatusStatisticsDTO;
import com.agileboot.domain.performance.submission.dto.SubmissionStatisticsDTO;
import com.agileboot.infrastructure.user.AuthenticationUtils;
import com.agileboot.infrastructure.user.web.SystemLoginUser;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 绩效统计控制器
 */
@Tag(name = "绩效统计API", description = "绩效统计相关的查询接口")
@RestController
@RequestMapping("/performance/statistics")
@RequiredArgsConstructor
public class StatisticsController {

    private final SubmissionApplicationService submissionApplicationService;

    @Operation(summary = "获取本人申报的项目数量信息和分数信息")
    @GetMapping("/mySubmissionStatistics")
    public ResponseDTO<SubmissionStatisticsDTO> getMySubmissionStatistics() {
        SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
        if (loginUser == null || loginUser.getUserId() == null) {
            return ResponseDTO.ok(null);
        }
        SubmissionStatisticsDTO statistics = submissionApplicationService.getUserSubmissionStatistics(loginUser.getUserId());
        return ResponseDTO.ok(statistics);
    }

}

